home *** CD-ROM | disk | FTP | other *** search
/ Internet Surfer 2.0 / Internet Surfer 2.0 (Wayzata Technology) (1996).iso / pc / text / mac / faqs.379 < prev    next >
Encoding:
Text File  |  1996-02-12  |  27.9 KB  |  700 lines

  1. Frequently Asked Questions (FAQS);faqs.379
  2.  
  3.  
  4.  
  5. Answer: You can't.  Text stores an ordinary string, and points where
  6. `highlights' of various types begin and end.  These highlights are all the
  7. control you have over components of the text.  See the previous question.
  8.  
  9.  
  10. -----------------------------------------------------------------------------
  11. Subject: 40) How can I change the font of text in the Text widget?  I want
  12. some of the text in one font, some in another.
  13.  
  14. Answer: You can't in Text (see the previous question).  If you wanted readonly
  15. text, you could do it by using a label instead.  Label uses XmStrings, which
  16. can contain multiple character sets in the one string.
  17.  
  18. -----------------------------------------------------------------------------
  19. Subject: 41) Is there an emacs binding for the text widget?
  20.  
  21. Answer: This set is due to Kee Hinckley (nazgul@alfalfa.com):
  22.  
  23. *XmText.translations: #override\n\
  24.         Ctrl <Key>b:            backward-character()\n\
  25.         Alt <Key>b:             backward-word()\n\
  26.         Meta <Key>b:            backward-word()\n\
  27.         Shift Alt <Key>b:       backward-word(extend)\n\
  28.         Shift Meta <Key>b:      backward-word(extend)\n\
  29.         Alt <Key>[:             backward-paragraph()\n\
  30.         Meta <Key>[:            backward-paragraph()\n\
  31.         Shift Alt <Key>[:       backward-paragraph(extend)\n\
  32.         Shift Meta <Key>[:      backward-paragraph(extend)\n\
  33.         Alt <Key><:             beginning-of-file()\n\
  34.         Meta <Key><:            beginning-of-file()\n\
  35.         Ctrl <Key>a:            beginning-of-line()\n\
  36.         Shift Ctrl <Key>a:      beginning-of-line(extend)\n\
  37.         Ctrl <Key>osfInsert:    copy-clipboard()\n\
  38.         Shift <Key>osfDelete:   cut-clipboard()\n\
  39.         Shift <Key>osfInsert:   paste-clipboard()\n\
  40.         Alt <Key>>:             end-of-file()\n\
  41.         Meta <Key>>:            end-of-file()\n\
  42.         Ctrl <Key>e:            end-of-line()\n\
  43.         Shift Ctrl <Key>e:      end-of-line(extend)\n\
  44.         Ctrl <Key>f:            forward-character()\n\
  45.         Alt <Key>]:             forward-paragraph()\n\
  46.         Meta <Key>]:            forward-paragraph()\n\
  47.         Shift Alt <Key>]:       forward-paragraph(extend)\n\
  48.         Shift Meta <Key>]:      forward-paragraph(extend)\n\
  49.         Ctrl Alt <Key>f:        forward-word()\n\
  50.         Ctrl Meta <Key>f:       forward-word()\n\
  51.         Ctrl <Key>d:            kill-next-character()\n\
  52.         Alt <Key>BackSpace:     kill-previous-word()\n\
  53.         Meta <Key>BackSpace:    kill-previous-word()\n\
  54.         Ctrl <Key>w:            key-select() kill-selection()\n\
  55.         Ctrl <Key>y:            unkill()\n\
  56.         Ctrl <Key>k:            kill-to-end-of-line()\n\
  57.         Alt <Key>Delete:        kill-to-start-of-line()\n\
  58.         Meta <Key>Delete:       kill-to-start-of-line()\n\
  59.         Ctrl <Key>o:            newline-and-backup()\n\
  60.         Ctrl <Key>j:            newline-and-indent()\n\
  61.         Ctrl <Key>n:            next-line()\n\
  62.         Ctrl <Key>osfLeft:      page-left()\n\
  63.         Ctrl <Key>osfRight:     page-right()\n\
  64.         Ctrl <Key>p:            previous-line()\n\
  65.         Ctrl <Key>g:            process-cancel()\n\
  66.         Ctrl <Key>l:            redraw-display()\n\
  67.         Ctrl <Key>osfDown:      next-page()\n\
  68.         Ctrl <Key>osfUp:        previous-page()\n\
  69.         Ctrl <Key>space:        set-anchor()\n
  70.  
  71.  
  72. ! If you'd like the Delete key to work like backspace instead of deleting
  73. ! backwards, add the following definition to the lines above.
  74. !       <Key>osfDelete: delete-previous-character()\n\
  75.  
  76. ! These aren't included because they could intefere with
  77. | menu accelerators (or vice versa)
  78. !       Alt <Key>p:             backward-paragraph()\n\
  79. !       Meta <Key>p:            backward-paragraph()\n\
  80. !       Shift Alt<Key>p:        backward-paragraph(extend)\n\
  81. !       Shift Meta<Key>p:       backward-paragraph(extend)\n\
  82. !       Alt <Key>w:             copy-clipboard()\n\
  83. !       Meta <Key>w:            copy-clipboard()\n\
  84. !       Ctrl Alt <Key>w:        cut-clipboard()\n\
  85. !       Ctrl Meta <Key>w:       cut-clipboard()\n\
  86. !       Alt <Key>y:             paste-clipboard()\n\
  87. !       Meta <Key>y:            paste-clipboard()\n\
  88. !       Alt <Key>f:             forward-word()\n\
  89. !       Meta <Key>f:            forward-word()\n\
  90. !       Alt <Key>n:             forward-paragraph()\n\
  91. !       Meta <Key>n:            forward-paragraph()\n\
  92. !       Shift Alt <Key>n:       forward-paragraph(extend)\n\
  93. !       Shift Meta <Key>n:      forward-paragraph(extend)\n\
  94. !       Shift Alt <Key>f:       forward-word(extend)\n\
  95. !       Shift Meta <Key>f:      forward-word(extend)\n\
  96. !       Alt <Key>d:             kill-next-word()\n\
  97. !       Meta <Key>d:            kill-next-word()\n\
  98. !       Alt <Key>h:             select-all()\n\
  99. !       Meta <Key>h:            select-all()\n\
  100.  
  101. Similar sets of translations have been suggested by others.
  102.  
  103. -----------------------------------------------------------------------------
  104. Subject: 42) How can I use a file as the text source for a Text widget?
  105.  
  106. Answer: You can't do it directly like you can with the Athena Text widget.
  107. Instead, read the text from the file into a string (all of it!) and then use
  108. XmTextSetString.  Alternatively, read blocks of characters and add them at the
  109. end of the text using XmTextInsertString.  The following is an excerpt from
  110. Dan Heller's "file_browser.c":
  111.  
  112.     /* file_browser.c -- use a ScrolledText object to view the
  113.      * contents of arbitrary files chosen by the user from a
  114.      * FileSelectionDialog or from a single-line text widget.
  115.      */
  116.  
  117.     ...
  118.     struct stat statb;
  119.  
  120.     /* make sure the file is a regular text file and open it */
  121.     if (stat(filename, &statb) == -1 ||
  122.             (statb.st_mode & S_IFMT) != S_IFREG ||
  123.             !(fp = fopen(filename, "r"))) {
  124.         if ((statb.st_mode & S_IFMT) == S_IFREG)
  125.             perror(filename); /* send to stderr why we can't read it */
  126.         else
  127.             fprintf(stderr, "%s: not a regular file0, filename);
  128.         XtFree(filename);
  129.         return;
  130.     }
  131.  
  132.     /* put the contents of the file in the Text widget by allocating
  133.      * enough space for the entire file, reading the file into the
  134.      * allocated space, and using XmTextFieldSetString() to show the file.
  135.      */
  136.     if (!(text = XtMalloc((unsigned)(statb.st_size+1)))) {
  137.         fprintf(stderr, "Can't alloc enough space for %s", filename);
  138.         XtFree(filename);
  139.         fclose(fp);
  140.         return;
  141.     }
  142.  
  143.     if (!fread(text, sizeof(char), statb.st_size+1, fp))
  144.         fprintf(stderr, "Warning: may not have read entire file!0);
  145.  
  146.     text[statb.st_size] = 0; /* be sure to NULL-terminate */
  147.  
  148.     /* insert file contents in Text widget */
  149.     XmTextSetString(text_w, text);
  150.  
  151.  
  152.  
  153.  
  154. -----------------------------------------------------------------------------
  155. Subject: 43) How can put Text in overstrike mode instead of insert?
  156.  
  157. Answer: There is no direct way. This was posted by Edmond Pitt
  158. (ejp@bohra.cpg.oz) The correct answer to the question is to put the following
  159. in a modifyVerify callback, where 'mvcb' is the XmTextVerifyCallbackStruct,
  160. and 'overstriking' is defined by you:
  161.  
  162.     if (overstriking && mvcb->text->length == 1)
  163.     {
  164.         _XmTextDisableRedisplay(w,FALSE);
  165.         XtCallActionProc(w,"delete-next-character",mvcb->event,0);
  166.         _XmTextEnableRedisplay(w);
  167.     }
  168.  
  169. _XmText{Dis,En}ableRedisplay() are XmText{Dis,En}ableRedisplay() in 1.0, but
  170. X11R3 has no XtCallActionProc() anyway. For this environment you need my 1.0.3
  171. Text widget patches posted last year & available on request.
  172.  
  173.  
  174. -----------------------------------------------------------------------------
  175. Subject: 44) How can I make the Delete key do a backspace?
  176.  
  177. Answer: Put this in your .Xdefaults
  178.  
  179.     *XmText.translations: #override <Key>osfDelete: delete-previous-character()
  180.  
  181.  
  182. -----------------------------------------------------------------------------
  183. Subject: 45) TOPIC: LIST WIDGET
  184.  
  185. -----------------------------------------------------------------------------
  186. Subject: 46) How do I best put a new set of items into a list?
  187.  
  188. Answer: Set the new list count and list by XtSetArgs and install them by
  189. XtSetValues.
  190.  
  191.     XmString list[SIZE];
  192.     int list_size;
  193.  
  194.     XtSetArg (args[n], XmNitemCount, list_size); n++;
  195.     XtSetArg (args[n], XmNitems, list); n++;
  196.     XtSetValues (w, args, n);
  197.  
  198. Each time the list is reset by this the old contents are freed by the widget
  199. and the new supplied list is copied.  Do *not* free the old list of items
  200. yourself as this would result in the space being freed twice.  It is not
  201. necessary to remove the items one at a time, nor to "zero" out the list first.
  202.  
  203. -----------------------------------------------------------------------------
  204. Subject: 47)  Can I have strings with different fonts in a list?
  205.  
  206. Answer: Yes. The strings are XmStrings. Each one can be created using a
  207. different character set using a different font.
  208.  
  209.  
  210. -----------------------------------------------------------------------------
  211. Subject: 48) Can I get a bitmap to show in a list item like I can in a Label?
  212. I want to place a bitmap along with some normal text in my list items.
  213.  
  214. Answer: No. The list contains XmStrings, and these only allow text in various
  215. character sets. The workaround is to define your font containing the icons you
  216. want. Then you can create a fontlist containing your icon font and the font
  217. you want the text in, and then make your items multi-segment XmStrings where
  218. the first segment contains the code of the icon you want with a charset that
  219. matches the icon font in your fontlist and the second segment with a charset
  220. matching the text font.
  221.  
  222.  
  223. -----------------------------------------------------------------------------
  224. Subject: 49) Can I have items with different colours in a list?
  225.  
  226. Answer: No.  The list contains XmStrings, and these only allow text in various
  227. character sets. Since the items are XmStrings, you can already change the font
  228. of an item by replacing it with an item with the same text and a different
  229. charset tag.  Adding support for color would require modification of the
  230. internal data structure in XmList as well as modification to the drawing
  231. routines.  A possible workaround is to use a rowcolumn of buttons which can be
  232. individually set.  However, you would have to do all list functionality
  233. yourself.
  234.  
  235.  
  236. -----------------------------------------------------------------------------
  237. Subject: 50) Can I grey out an item in a list?  I want to make insensitive
  238. items in a list so that they cannot be selected.
  239.  
  240. Answer:
  241.  
  242. From W. Scott Meeks of OSF:
  243.  
  244. Unfortunately, you can't do it directly since the list items aren't individual
  245. widgets.  We've had other requests for this technology, but it didn't make the
  246. cut for 1.2; it should be in some future release.
  247.  
  248. However, you can probably fake it in your application with some difficulty.
  249. First, a list item is an XmString, so you can specify a different charset for
  250. the item than for other items in the list and then specify a font in the
  251. list's fontlist that matches the charset and gives you the visual you want.
  252. The next problem is making the item unselectable.  One idea would be to have
  253. the application keep track of the insensitive items and the items currently
  254. selected.  Then you would set up a selection callback that when called would
  255. check the item selected against the list of insensitive items and if the
  256. selected item matched would deselect that item and reselect the previously
  257. selected items.  Otherwise it would just update the application's list of
  258. selected items.  The major drawback with this approach is that you'll get
  259. flashing whenever the list selects an item and your application immediately
  260. de-selects.  Unfortunately I can't think of a way around this without mucking
  261. with the list internals.
  262.  
  263. Another alternative suggested is to use instead a column of say read only text
  264. widgets which you can make insensitive.
  265.  
  266. -----------------------------------------------------------------------------
  267. Subject: 51)  Can I have multi-line items in a list?
  268. [Last modified: August 92]
  269.  
  270. Answer: Motif 1.0 and 1.1 both have problems with multi-line items in a list.
  271. They should work okay in Motif 1.2.
  272.  
  273. -----------------------------------------------------------------------------
  274. Subject: 52)+How can I tell the position of selected items in a list?
  275.  
  276. [Last modified: Oct 92]
  277.  
  278. Answer: From  W. Scott Meeks:
  279.  
  280. 1) All XmList selection callbacks get an XmListCallbackStruct which includes
  281. the item selected and its position.  In addition, the multiple and extended
  282. selection callbacks also get a list of the selected items.  This approach
  283. requires that your application saves this information if you need it outside
  284. of the immediate callback.
  285.  
  286. 2) At any time you can XtGetValues the XmNselectedItems and
  287. XmNselectedItemCount resources.  The problem with this approach is that
  288. identical items may or may not show up in multiple times in this list and the
  289. position in the selectedItems list may not relate directly to the position in
  290. the items list.
  291.  
  292. 3) You can call XmListGetSelectedPos on the list widget.  This will return a
  293. list of the positions of all selected items.
  294.  
  295. -----------------------------------------------------------------------------
  296. Subject: 53) TOPIC: FILE SELECTION BOX WIDGET
  297.  
  298. -----------------------------------------------------------------------------
  299. Subject: 54) What is libPW.a and do I need it?  My manual says I need to link
  300. in libPW.a to use the File Selection Box.  I can't find it on my system.
  301.  
  302. Answer: The libPW.a is the Programmers Workbench library which is an ATT
  303. product not included in Berkeley based systems, hence it is not found in SunOS
  304. or Ultrix, but is found on HP-UX (a Berkeley/ATT hybrid which chose ATT in
  305. this case).  It contains the regex(3) routines (regcmp, regex).  Some systems
  306. which don't have these in the libc.a need to link with -lPW.  Some systems
  307. which have the regex(3) routines in there also have the libPW.a.  If you have
  308. regex(3) in libc, and it works, don't link with libPW.  If you don't have
  309. regex(3) in libc, and you don't have a libPW, then check some sites on the net
  310. for public domain replacements (several exist), or call your vendor.
  311.  
  312. In most versions of Motif (see the doco), you can compile FileSB.c with
  313. -DNO_REGEX if you don't have it.
  314.  
  315. -----------------------------------------------------------------------------
  316. Subject: 55) What are these compile errors: Undefined symbol _regcmp?
  317.  
  318. Answer: You need to link in the libPW library - see previous question.
  319.  
  320.  
  321. -----------------------------------------------------------------------------
  322. Subject: 56) What's wrong with the Motif 1.0 File Selection Box?  I can't set
  323. the directory, change the directory or get the file mask to work.
  324.  
  325. Answer: The 1.0 File Selection Box is broken, and these don't work.  They
  326. weren't fixed until Motif 1.04.  Use these later versions of 1.0 or switch to
  327. Motif 1.1 where it changed a lot.
  328.  
  329. Joe Hildebrand has a work-around for some of this: Before popping up an
  330. XmFileSelectionDialog, change to the directory you want.  When a file is
  331. selected, check if it is a directory, so that we can change to it.  i.e.
  332.  
  333. static void show_file_box_CB(w, client_data, call_data)
  334.    Widget               w;
  335.    Widget               client_data;
  336.    XmAnyCallbackStruct  *call_data;
  337. {
  338.    chdir("/users/hildjj/files");
  339.    XtManageChild(client_data);
  340. }
  341.  
  342. static void val_save(w, client_data, call_data)
  343.    Widget       w;
  344.    Widget       client_data;
  345.    XmSelectionBoxCallbackStruct *call_data;
  346. {
  347.    struct stat buf;  /* struct stat is defined in stat.h */
  348.    char *filename;
  349.  
  350.    /* get the file name from the FileSelectionBox */
  351.    filename = SmX(call_data->value);
  352.  
  353.    /* get the status of the file named filename, and put it into buf */
  354.    if (!stat(filename, &buf))
  355.    {
  356.       /* if it's a directory */
  357.       /* if it's a directory */
  358.       if(S_ISDIR(buf.st_mode))
  359.       {
  360.          /* change to that directory, and update the FileSelectionBox */
  361.         chdir(filename);
  362.         XmFileSelectionDoSearch(w, NULL);
  363.       }
  364.       else
  365.          /* if it's a regular file */
  366.          if(S_ISREG(buf.st_mode))
  367.             /* ask if it should be overwritten */
  368.             XtManageChild(valbox);
  369.          else
  370.             /* it's another kind of file.  What type, i can't think of,
  371.                but it might happen */
  372.             pop_up_error_box(client_data, "Error saving file");
  373.    }
  374.    else  /* we couldn't get the file status */
  375.    {
  376.       /* if it's because the file doesn't exist, we're golden */
  377.       if (errno == ENOENT)
  378.          save_file();
  379.       else   /* there is some other problem getting the status.
  380.                 e.g. bad path */
  381.          pop_up_error_box(client_data, "Error saving file");
  382.    }
  383. }
  384.  
  385. this still doesn't implement the file masking stuff.
  386.  
  387.  
  388. -----------------------------------------------------------------------------
  389. END OF PART TWO
  390. --
  391. +----------------------+---+
  392.   Jan Newmarch, Information Science and Engineering,
  393.   University of Canberra, PO Box 1, Belconnen, Act 2616
  394.   Australia. Tel: (Aust) 6-2012422. Fax: (Aust) 6-2015041
  395. Xref: bloom-picayune.mit.edu comp.windows.x.motif:13659 news.answers:4510
  396. Newsgroups: comp.windows.x.motif,news.answers
  397. Path: bloom-picayune.mit.edu!enterpoop.mit.edu!news.media.mit.edu!micro-heart-of-gold.mit.edu!wupost!uunet!munnari.oz.au!manuel.anu.edu.au!csc.canberra.edu.au!news
  398. From: jan@ise.canberra.edu.au (Jan Newmarch)
  399. Subject: Motif FAQ (Part 3 of 5)
  400. Message-ID: <1992Dec10.001621.10506@csc.canberra.edu.au>
  401. Followup-To: comp.windows.x.motif
  402. Keywords: FAQ question answer
  403. Sender: news@csc.canberra.edu.au
  404. Reply-To: jan@ise.canberra.edu.au (Jan Newmarch)
  405. Organization: University of Canberra
  406. Date: Thu, 10 Dec 92 00:16:21 GMT
  407. Approved: news-answers-request@MIT.Edu
  408. Expires: +1 months
  409. Lines: 1147
  410.  
  411. Archive-name: motif-faq/part3
  412. Last-modified: Thu December 12 1992
  413. Version: 2.12
  414.  
  415.  
  416.  
  417. -----------------------------------------------------------------------------
  418. Subject: 57) TOPIC: FORM WIDGET
  419.  
  420.  
  421. -----------------------------------------------------------------------------
  422. Subject: 58) Why don't labels in a Form resize when the label is changed?
  423. I've got some labels in a form. The labels don't resize whenever the label
  424. string resource is changed. As a result, the operator has to resize the window
  425. to see the new label contents. I am using Motif 1.1.
  426.  
  427. Answer: This problem may happen to any widget inside a Form widget. The
  428. problem was that the Form will resize itself when it gets geometry requests
  429. from its children. If its preferred size is not allowed, the Form will
  430. disallow all geometry requests from its children. The workaround is that you
  431. should set any ancestor of the Form to be resizable. For the shell which
  432. contains the Form you should set the shell resource XmNallowShellResize to be
  433. True (by default, it is set to FALSE).  There is currently an inconsistency on
  434. how resizing is being done, and it may get fixed in Motif 1.2.
  435.  
  436. From db@sunbim.be (Danny Backx)
  437.  
  438. Basically what you have to do is set the XmNresizePolicy on the Form to
  439. XmRESIZE_NONE.  The facts seem to be that XmRESIZE_NONE does NOT mean "do not
  440. allow resizes".  You may also have to set XmNresizable on the form to True.
  441.  
  442. -----------------------------------------------------------------------------
  443. Subject: 59) How can I center a widget in a form?
  444.  
  445. Answer: One of Motif's trickier questions.  The problems are that: Form gives
  446. no support for centering, only for edge attachments, and the widget must stay
  447. in the center if the form or the widget is resized.  Just looking at
  448. horizontal centering (vertical is similar) some solutions are:
  449.  
  450.  a.  Use the table widget instead of Form.
  451.  
  452.  b.  A hack free solution is from Dan Heller:
  453.  
  454.      /* Written by Dan Heller.  Copyright 1991, O'Reilly && Associates.
  455.       * This program is freely distributable without licensing fees and
  456.       * is provided without guarantee or warranty expressed or implied.
  457.       * This program is -not- in the public domain.  This program is
  458.       * taken from the Motif Programming Manual, O'Reilly Volume 6.
  459.       */
  460.  
  461.      /* corners.c -- demonstrate widget layout management for a
  462.       * BulletinBoard widget.  There are four widgets each labeled
  463.       * top-left, top-right, bottom-left and bottom-right.  Their
  464.       * positions in the bulletin board correspond to their names.
  465.       * Only when the widget is resized does the geometry management
  466.       * kick in and position the children in their correct locations.
  467.       */
  468.      #include <Xm/BulletinB.h>
  469.      #include <Xm/PushBG.h>
  470.  
  471.      char *corners[] = {
  472.          "Top-Left", "Top-Right", "Bottom-Left", "Bottom-Right",
  473.      };
  474.  
  475.      static void resize();
  476.  
  477.      main(argc, argv)
  478.      int argc;
  479.      char *argv[];
  480.      {
  481.          Widget toplevel, bboard;
  482.          XtAppContext app;
  483.          XtActionsRec rec;
  484.          int i;
  485.  
  486.          /* Initialize toolkit and create toplevel shell */
  487.          toplevel = XtVaAppInitialize(&app, "Demos", NULL, 0,
  488.              &argc, argv, NULL, NULL);
  489.  
  490.          /* Create your standard BulletinBoard widget */
  491.          bboard = XtVaCreateManagedWidget("bboard",
  492.              xmBulletinBoardWidgetClass, toplevel, NULL);
  493.  
  494.          /* Set up a translation table that captures "Resize" events
  495.           * (also called ConfigureNotify or Configure events).  If the
  496.           * event is generated, call the function resize().
  497.           */
  498.          rec.string = "resize";
  499.          rec.proc = resize;
  500.          XtAppAddActions(app, &rec, 1);
  501.          XtOverrideTranslations(bboard,
  502.              XtParseTranslationTable("<Configure>: resize()"));
  503.  
  504.          /* Create children of the dialog -- a PushButton in each corner. */
  505.          for (i = 0; i < XtNumber(corners); i++)
  506.              XtVaCreateManagedWidget(corners[i],
  507.                  xmPushButtonGadgetClass, bboard, NULL);
  508.  
  509.          XtRealizeWidget(toplevel);
  510.          XtAppMainLoop(app);
  511.      }
  512.  
  513.      /* resize(), the routine that is automatically called by Xt upon the
  514.       * delivery of a Configure event.  This happens whenever the widget
  515.       * gets resized.
  516.       */
  517.      static void
  518.      resize(w, event, args, num_args)
  519.      CompositeWidget w;   /* The widget (BulletinBoard) that got resized */
  520.      XConfigureEvent *event;  /* The event struct associated with the event */
  521.      String args[]; /* unused */
  522.      int *num_args; /* unused */
  523.      {
  524.          WidgetList children;
  525.          int width = event->width;
  526.          int height = event->height;
  527.          Dimension w_width, w_height;
  528.          short margin_w, margin_h;
  529.  
  530.          /* get handle to BulletinBoard's children and marginal spacing */
  531.          XtVaGetValues(w,
  532.              XmNchildren, &children,
  533.              XmNmarginWidth, &margin_w,
  534.              XmNmarginHeight, &margin_h,
  535.              NULL);
  536.  
  537.          /* place the top left widget */
  538.          XtVaSetValues(children[0],
  539.              XmNx, margin_w,
  540.  
  541.              XmNy, margin_h,
  542.              NULL);
  543.  
  544.          /* top right */
  545.          XtVaGetValues(children[1], XmNwidth, &w_width, NULL);
  546.  
  547.          /* To Center a widget in the middle of the BulletinBoard (or Form),
  548.           * simply call:
  549.           *   XtVaSetValues(widget,
  550.                XmNx,    (width - w_width)/2,
  551.                XmNy,    (height - w_height)/2,
  552.                NULL);
  553.           * and return.
  554.           */
  555.          XtVaSetValues(children[1],
  556.              XmNx, width - margin_w - w_width,
  557.              XmNy, margin_h,
  558.              NULL);
  559.          /* bottom left */
  560.          XtVaGetValues(children[2], XmNheight, &w_height, NULL);
  561.          XtVaSetValues(children[2],
  562.  
  563.              XmNx, margin_w,
  564.              XmNy, height - margin_h - w_height,
  565.              NULL);
  566.          /* bottom right */
  567.          XtVaGetValues(children[3],
  568.              XmNheight, &w_height,
  569.              XmNwidth, &w_width,
  570.              NULL);
  571.          XtVaSetValues(children[3],
  572.              XmNx, width - margin_w - w_width,
  573.              XmNy, height - margin_h - w_height,
  574.              NULL);
  575.      }
  576.  
  577.  c.  No uil solution has been suggested, because of the widget size problem
  578.  
  579. -----------------------------------------------------------------------------
  580. Subject: 60) How do I line up two columns of widgets of different types?  I
  581. have a column of say label widgets, and a column of text widgets and I want to
  582. have them lined up horizontally. The problem is that they are of different
  583. heights. Just putting them in a form or rowcolumn doesn't line them up
  584. properly because the label and text widgets are of different height.
  585.  
  586. If you want the geometry to look like this
  587.  
  588.           -------------------------------------
  589.          |          -------------------------- |
  590.          |a label  |Some text                 ||
  591.          |          -------------------------- |
  592.                            ------------------- |
  593.          |a longer label  |Some more text     ||
  594.          |                 ------------------- |
  595.          |                    ---------------- |
  596.          |a very long label  |Even more text  ||
  597.          |                    ---------------- |
  598.           -------------------------------------
  599.  
  600. try
  601.  
  602. /* Written by Dan Heller.  Copyright 1991, O'Reilly && Associates.
  603.  * This program is freely distributable without licensing fees and
  604.  * is provided without guarantee or warranty expressed or implied.
  605.  * This program is -not- in the public domain.  This program is
  606.  * taken from the Motif Programming Manual, O'Reilly Volume 6.
  607.  */
  608.  
  609. /* text_form.c -- demonstrate how attachments work in Form widgets.
  610.  * by creating a text-entry form type application.
  611.  */
  612.  
  613. #include <Xm/PushB.h>
  614. #include <Xm/PushBG.h>
  615. #include <Xm/LabelG.h>
  616. #include <Xm/Text.h>
  617. #include <Xm/Form.h>
  618.  
  619. char *prompts[] = {
  620.     "Name:", "Phone:", "Address:",
  621.     "City:", "State:", "Zip:",
  622. };
  623.  
  624. main(argc, argv)
  625. int argc;
  626. char *argv[];
  627. {
  628.     Widget toplevel, mainform, subform, label, text;
  629.     XtAppContext app;
  630.     char buf[32];
  631.     int i;
  632.  
  633.     toplevel = XtVaAppInitialize(&app, "Demos", NULL, 0,
  634.         &argc, argv, NULL, NULL);
  635.  
  636.     mainform = XtVaCreateWidget("mainform",
  637.         xmFormWidgetClass, toplevel,
  638.         NULL);
  639.  
  640.     for (i = 0; i < XtNumber(prompts); i++) {
  641.         subform = XtVaCreateWidget("subform",
  642.             xmFormWidgetClass,   mainform,
  643.             /* first one should be attached for form */
  644.             XmNtopAttachment,    i? XmATTACH_WIDGET : XmATTACH_FORM,
  645.             /* others are attached to the previous subform */
  646.             XmNtopWidget,        subform,
  647.             XmNleftAttachment,   XmATTACH_FORM,
  648.             XmNrightAttachment,  XmATTACH_FORM,
  649.             NULL);
  650.         label = XtVaCreateManagedWidget(prompts[i],
  651.             xmLabelGadgetClass,  subform,
  652.             XmNtopAttachment,    XmATTACH_FORM,
  653.             XmNbottomAttachment, XmATTACH_FORM,
  654.             XmNleftAttachment,   XmATTACH_FORM,
  655.             XmNalignment,        XmALIGNMENT_BEGINNING,
  656.             NULL);
  657.         sprintf(buf, "text_%d", i);
  658.         text = XtVaCreateManagedWidget(buf,
  659.             xmTextWidgetClass,   subform,
  660.             XmNtopAttachment,    XmATTACH_FORM,
  661.             XmNbottomAttachment, XmATTACH_FORM,
  662.             XmNrightAttachment,  XmATTACH_FORM,
  663.             XmNleftAttachment,   XmATTACH_WIDGET,
  664.             XmNleftWidget,       label,
  665.             NULL);
  666.         XtManageChild(subform);
  667.     }
  668.     /* Now that all the forms are added, manage the main form */
  669.     XtManageChild(mainform);
  670.  
  671.     XtRealizeWidget(toplevel);
  672.     XtAppMainLoop(app);
  673. }
  674.  
  675. If you resize horizontally it stretches the text widgets.  If you resize
  676. vertically it leaves space under the bottom (if you don't resize, this is not
  677. problem).
  678.  
  679. If you want the text widgets to be lined up on the left, as in
  680.  
  681.           ----------------------------------------
  682.          |                    ------------------- |
  683.          |          a label  |Some text          ||
  684.          |                    ------------------- |
  685.                               ------------------- |
  686.          |   a longer label  |Some more text     ||
  687.          |                    ------------------- |
  688.          |                    ------------------- |
  689.          |a very long label  |Even more text     ||
  690.          |                    ------------------- |
  691.           ----------------------------------------
  692.  
  693. try this
  694.  
  695. /* Written by Dan Heller.  Copyright 1991, O'Reilly && Associates.
  696.  * This program is freely distributable without licensing fees and
  697.  * is provided without guarantee or warranty expressed or implied.
  698.  * This program is -not- in the public domain.  This program is
  699.  * taken from the Motif Programming Manual, O'Reilly Volume 6.
  700.